<html>
<head>
	<meta charset="UTF-8">
	<title>usercontroller</title>
</head>
<body>
	<?php 
require 'Home/Model/IndexModel.php';
require 'Controller.php';
class IndexController extends Controller{
function __construct(){
parent::__construct();
}
function index(){
	$model=new IndexModel();
	$data1=$model->getVideo1();
	$data2=$model->getVideo2();
	$data3=$model->getVideo3();
	$data4=$model->getVideo4();
	
	$this->assign('video1',$data1);
	$this->assign('video2',$data2);
	$this->assign('video3',$data3);
	$this->assign('video4',$data4);

	$this->display();
	//return $data;

}
function reguser(){
	$this->display();
}
function adduser(){
	$data=$_POST;
	$file=$_FILES;
	$model=new IndexModel();
	$result=$model->adduser($data,$file);
	if ($result) {
		echo "注册成功，3秒后返回首页。";
		header("refresh:3;url='index.php?c=index&m=index'");
	}else{
		echo "注册失败，3秒后返回注册页重新注册。";
		header("refresh:3;url='index.php?c=index&m=reguser'");
	}
}

function listall(){
	$tid=$_GET['tid'];
	$model=new IndexModel();
	$data=$model->listall($tid);
	$this->assign('allvideos',$data);

	$this->display();
}
function show(){
$vid=$_GET['vid'];
$model=new IndexModel();
	$data=$model->show($vid);
	$this->assign('videoinfor',$data);

	$this->display();
}
function login(){
	$this->display();
}
function dologin(){
	$data=$_POST;
	$model=new IndexModel();
	$result=$model->dologin($data);
	if ($result) {
		session_start();
		$_SESSION['user']=$data['username'];
		echo "登录成功，3秒后返回首页。";
		header("refresh:3;url='index.php?c=index&m=index'");
	}else{
		echo "登录失败，3秒后返回登录页重新登录。";
		header("refresh:3;url='index.php?c=index&m=login'");
	}
}
function logout(){
	session_start();
	session_destroy();
	echo "注销成功，3秒后返回主页面";
	header("refresh:3;url='index.php?c=index&m=index'");
}
}
	 ?>
</body>
</html>